package Object;

import java.util.Objects;

public class Student {
    private String name;
    private int age;

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;//判断是否为同一个对象
        if (o == null || getClass() != o.getClass()) return false;//非空判断
        Student student = (Student) o;//将父类Object强转为子类student类型
        return age == student.age && Objects.equals(name, student.name);
        //比较内部属性值(equals方法调用者是s1)this.age(s1的age)==student.age(s2的age)
    }


    @Override
    protected Object clone() throws CloneNotSupportedException {
        return super.clone();
    }

    @Override
    protected void finalize() throws Throwable {
        super.finalize();
    }

    public Student() {

    }public Student(String name, int age) {
        this.name = name;
        this.age = age;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public int getAge() {
        return age;
    }

    public void setAge(int age) {
        this.age = age;
    }

    @Override
    public String toString() {
        return name+","+age;
    }
}
